<template>
	<view class="content-header">
		<view class="add-header-cen">
			<view class="add-header flex-row flex-content-between">
				<view v-for="(tab,index) in tabList">
					<view :class="index==current?`add-header-ac`:`add-header-nc`" @tap="changeTab(index)">
						{{tab.name}}
					</view>
				</view>
			</view>
		</view>
		<view v-if="tabList[current].data.length==0">
			<view class="not-img">
				<image src="../../static/bank/notbank.png" mode="scaleToFill"></image>
				<view class="not-txt">暂无卡片</view>
			</view>
			<view class="flex-row flex-content-center">
				<view class="not-btn" @tap="toaddbank(current)">添加银行卡</view>
			</view>
		</view>
		<view v-if="tabList[current].data.length>0">
			<scroll-view :scroll-y="true" class="data-list">
				<view class="top30"></view>
				<view v-for="(item,index) in tabList[current].data" class="ones">
					<view class="flex-row flex-content-between ones-top">
						<view class="flex-row">
							<image class="bankimg" src="../../static/order/yh.png" mode="heightFix"></image>
							<view class="flex-column bank-txt">
								<view>中国银行</view>
								<view>储蓄卡</view>
								<view>******  *******  2566</view>
							</view>
						</view>
						<view class="flex-row bank-action">
							<view @tap="deleteBank(index)">删除</view>
							<view></view>
							<view @tap="gochange(item,current)">修改</view>
						</view>
					</view>
				</view>
			</scroll-view>
			<mu-suspension bottom="46">
				<view class="foot flex-row flex-content-center">
					<view @tap="toaddbank(current)">添加新卡</view>
				</view>
			</mu-suspension>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				current:0,
				tabList:[
					{
						name:"储蓄卡",
						data:[
						]
					},
					{
						name:"信用卡",
						data:[
							"",
							"",
							"",
							"",
							"",
							"",
							"",
							"",
							"",
							"",
							"",
							"",
							""
						]
					}
				]
			}
		},
		methods:{
			//选择tab
			changeTab(index){
				this.current = index
			},
			//跳转到添加
			toaddbank(index){
				console.log(index);
				var title = "添加到账储蓄卡"
				if(index!=0){
					title = '添加信用卡'
				}
				uni.navigateTo({
					url:'/pages/bank/add_bank?current='+index+"&title="+title
				})
			},
			//删除银行卡
			deleteBank(index){
				var data = this.tabList[this.current].data;
				var that = this;
				uni.showModal({
					title:"删除银行卡后不可恢复",
					content:"确认删除此卡吗？",
					success(res) {
						if(res.confirm){
							data.splice(index,1)
							that.tabList[that.current].data = data;
						}
					}
				})
			},
			//修改银行卡
			gochange(item,type){
				var title = "修改储蓄卡"
				if(this.current==1){
					title = '修改信用卡'
				}
				uni.navigateTo({
					url:'/pages/bank/change_bank?type='+type+'&title='+title
				})
			}
		}
	}
</script>

<style lang="scss">
	.foot{
		width: 750rpx;
		>view{
			width: 400rpx;
			height: 90rpx;
			background: linear-gradient(90deg, $default-button-color 0%, $default-button-end-color 100%);
			border-radius: 45rpx 45rpx 45rpx 45rpx;
			opacity: 1;
			font-size: 30rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: $default-button-foncolor;
			text-align: center;
			line-height: 90rpx;
		}
	}
	.bank-action{
		>view:nth-child(1){
			font-size: 28rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
		}
		>view:nth-child(2){
			width: 0px;
			height: 17rpx;
			opacity: 1;
			border-left: 1px solid #707070;
			margin-left: 16rpx;
			margin-top: 12rpx;
		}
		>view:nth-child(3){
			font-size: 28rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
			margin-left: 16rpx;
		}
	}
	.bank-txt{
		margin-left: 20rpx;
		>view:nth-child(1){
			font-size: 30rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
		}
		>view:nth-child(2){
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			margin-top: 10rpx;
		}
		>view:nth-child(3){
			font-size: 28rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
			margin-top: 15rpx;
		}
	}
	.bankimg{
		// width: 40rpx;
		height: 40rpx;
	}
	.ones-top{
		padding-top: 31rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		padding-bottom: 30rpx;
	}
	.ones{
		width: 690rpx;
		// height: 191rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		opacity: 1;
		margin-bottom: 20rpx;
	}
	/* #ifdef H5 */
	.data-list{
		width: 690rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		height: calc(100vh - 210rpx - 140rpx);
		// background-color: #55ff7f;
		padding-bottom: 150rpx;
		// margin-bottom: 150rpx;
	}
	/* #endif */
	/* #ifdef APP-PLUS */
	.data-list{
		width: 690rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		height: calc(100vh - 210rpx - 60rpx);
		// background-color: #55ff7f;
		padding-bottom: 150rpx;
		// margin-bottom: 150rpx;
	}
	/* #endif */
	/* #ifdef MP */
	.data-list{
		width: 690rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		height: calc(100vh - 210rpx - 40rpx);
		// background-color: #55ff7f;
		padding-bottom: 150rpx;
		// margin-bottom: 150rpx;
	}
	/* #endif */
	.not-btn{
		width: 400rpx;
		height: 90rpx;
		background: linear-gradient(90deg,$default-button-color 0%, $default-button-end-color 100%);
		border-radius: 45rpx 45rpx 45rpx 45rpx;
		opacity: 1;
		margin-top: 81rpx;
		font-size: 30rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: $default-button-foncolor;
		text-align: center;
		line-height: 90rpx;
	}
	.not-txt{
		font-size: 26rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		text-align: center;
		margin-top: 10rpx;
	}
	.not-img{
		>image{
			width: 260rpx;
			height: 260rpx;
			margin-top: 180rpx;
			margin-left: 245rpx;
		}
	}
	.add-header-ac{
		font-size: 32rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: $default-button-color;
		width: 210rpx;
		border-bottom:3rpx solid $default-button-color ;
		text-align: center;
		padding-bottom: 18rpx;
	}
	.add-header-nc{
		font-size: 32rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		width: 210rpx;
		text-align: center;
	}
	.add-header-cen{
		width: 750rpx;
		height: 67rpx;
		background-color: #FFFFFF;
		padding-top: 45rpx;
		
	}
	.add-header{
		width: 560rpx;
		margin-left: 95rpx;
		margin-right: 95rpx;
	}
</style>